package com.example.rabbitmq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    //交换机
    @Bean
    DirectExchange directExchange() {
        return new DirectExchange("heJun_test_exchange");
    }

    //消息队列
    @Bean
    Queue queue() {
        return new Queue("heJun_test_queue");
    }

    //指定一个交换机和消息队列进行绑定，并且指定了一个Key
    @Bean
    Binding binding(){
        return BindingBuilder.bind(queue()).to(directExchange()).with("heJun_test_key");
    }
}
